/*基础*/
var wza_breaksent
function $(sele){return document.querySelector(sele)}
function setCookie(cn,cc,cl){var dat=new Date();dat.setTime(dat.getTime()+(cl*24*60*60*1000));document.cookie=cn+"="+cc+";path=/;"+cl;}
function getCookie(cn){var name=cn+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i].trim();if (c.indexOf(name)==0){return c.substring(name.length,c.length);}}return "";}
function loadjs(target){var script=document.createElement("script");script.type="text/javascript";script.src=target;document.body.appendChild(script);console.log('加载'+target);}
/*辅助线*/
function guidelinestart(){setCookie('guideline','true');document.body.innerHTML='<div class="guidelines_hor"></div><div class="guidelines_ver"></div>'+document.body.innerHTML;document.addEventListener('mousemove',function(event){var hor_h="3";var ver_w="3";document.querySelector(".guidelines_hor").setAttribute("style","display:block;top:"+(event.clientY-2*hor_h)+"px"),document.querySelector(".guidelines_ver").setAttribute("style","display:block;left:"+(event.clientX-2*ver_w)+"px")});document.querySelector(".guidelines_hor").style.display="inline";document.querySelector(".guidelines_ver").style.display="inline";}
function guidelinestop(){setCookie('guideline','false');document.removeEventListener('mousemove',function(){throw Error('辅助线关闭')});location.reload();}
function guideline(){if(getCookie('guideline')=='true'){guidelinestop();}else{guidelinestart();}}
if(getCookie('guideline')=='true'){guidelinestart();}
/*字体*/
function largefnt(){document.querySelector('body').setAttribute('style','font-size:1.2em;');setCookie('fntsize','large');}
function mediumfnt(){document.querySelector('body').setAttribute('style','font-size:1em;');setCookie('fntsize','medium');}
function smallfnt(){document.querySelector('body').setAttribute('style','font-size:0.8em;');setCookie('fntsize','small');}
function normalfnt(){document.querySelector('body').setAttribute('style','font-size:unset;');setCookie('fntsize','normal');}
var fntNset=getCookie('fntsize');if(fntNset=='large'){largefnt();}if(fntNset=='medium'){mediumfnt();}if(fntNset=='small'){smallfnt();}
/*高亮选定*/
function hovstart(){document.styleSheets[0].insertRule("a:hover,button:hover,input:hover,select:hover,textarea:hover{outline:5px solid #ff0000;}");setCookie('hover','true');}
function hovstop(){document.styleSheets[0].removeRule("a:hover,button:hover,input:hover,select:hover,textarea:hover{outline:5px solid #ff0000;}");setCookie('hover','false');}
function hov(){if(getCookie('hover')=='true'){hovstop();}else{hovstart();}}
var hovNset=getCookie('hover');if(hovNset=='true'){hovstart();}
/*断句辅助*/
function breaksstart(){setCookie('break','true');if(!wza_breaksent){loadjs("break.js");}wza_breaksent=true;}
function breaksstop(){setCookie('break','');wza_breaksent=false;location.reload();}
function breaks(){if(getCookie('break')=='true'){breaksstop();}else{breaksstart();}}
var bakNset=getCookie('break');if(bakNset=='true'){setTimeout("breaksstart()",500);}
/*大字幕*/
function subtitlestart(){setCookie('st','true');breaksstart();setTimeout("subt_start();",500);}
function subtitlestop(){setCookie('st','');breaksstop();}
function subtitle(){if(getCookie('st')=='true'){subtitlestop();}else{subtitlestart();}}
var sttNset=getCookie('st');if(sttNset=='true'){setTimeout("subtitlestart()",500);}
/*大鼠标*/
function bigcursorstart(){setCookie('bcur','true');$("body").setAttribute('wza_cur','y');}
function bigcursorstop(){setCookie('bcur','');$("body").removeAttribute('wza_cur');}
function bigcursor(){if(getCookie('bcur')=='true'){bigcursorstop();}else{setTimeout("bigcursorstart()",500);}}
var bcrNset=getCookie('bcur');if(bcrNset=='true'){setTimeout("bigcursorstart()",500);}
/*朗读（仅适用于部分浏览器）*/
function ttsstart(){setCookie('tts','true');breaksstart();setTimeout("tts_start();",600);}
function ttsstop(){setCookie('tts','');breaksstop();}
function tts(){if(getCookie('tts')=='true'){ttsstop();}else{ttsstart();}}
function wza_say(content){var saythis=new window.SpeechSynthesisUtterance(content);window.speechSynthesis.cancel();window.speechSynthesis.speak(saythis);}
var ttsNset=getCookie('tts');if(ttsNset=='true'){setTimeout("ttsstart();",500);}
/*加载*/
if($("div#wza")){$("div#wza").innerHTML=`<a onclick="window.print();">打印本页</a> | <a>字体大小</a>：<a onclick="largefnt();">大</a> <a onclick="mediumfnt();">中</a> <a onclick="smallfnt();">小</a> <a onclick="normalfnt();">默认</a> | <a onclick="bigcursor();">大鼠标</a> <a onclick="guideline();">鼠标辅助线</a> <a onclick="hov();">选定辅助</a> | <a onclick="tts();">朗读</a> | <a onclick="subtitle()">大字幕辅助</a>`}